<%@page import="com.xcalendar.database.table.User"%>
<%@page import="com.xcalendar.constant.XConstants"%>
<%@page import="com.xcalendar.database.table.Event"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
	<%
	
	String errorMessage = (String)request.getAttribute(XConstants.WRONY_MESSAGE);
	if(request.getSession().getAttribute(XConstants.SESSION_USER)==null){
		//System.out.println("null");
		//response.setContentType("text/plain");
		//response.getWriter().println("not logged");
	}else{
		if(request.getSession().getAttribute(XConstants.ISLOGGED).equals("true")){
			System.out.println("logged");
			//response.setContentType("text/plain");
			//response.getWriter().println("logged");
			%><jsp:forward page="homepage_calendar.jsp"/><%
		}
	}
	%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.css' />
<link rel='stylesheet' type='text/css' href='../css/ui-lightness/jquery-ui-1.8.16.custom.css' />
<link rel='stylesheet' type='text/css' href='../fullcalendar/fullcalendar.print.css' media='print' />
<script type='text/javascript' src='../jquery/jquery-1.6.2.min.js'></script>
<script type='text/javascript' src='../jquery/jquery-ui-1.8.16.custom.min.js'></script>
<script type='text/javascript' src='../fullcalendar/fullcalendar.min.js'></script>
<style type='text/css'>
body {
	margin-top: 40px;
	text-align: center;
	font-size: 14px;
	font-family: "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
	color: #007fff;
	background-image:url(../bg/6_3.jpg); 
	background-position: center;
	background-attachment: fixed;
	repeat-x: #FFFFFF
	
}


</style>
<title>Login Page</title>
<script type="text/javascript">
	function validate_required(field, alerttxt) {
		with (field) {
			if (value == null || value == "") {
				alert(alerttxt);
				return false;
			} else {
				return true;
			}
		}
	}

	function validate_form(thisform) {
		with (thisform) {
			if (validate_required(userName, "User Name must be filled out!") == false) {
				userName.focus();
				return false;
			}
			else if (validate_required(password, "Password must be filled out!") == false) {
				password.focus();
				return false;
			}
		}
	}
</script>
<script>
	$(function() {
		$( "input:submit, a, button", ".link" ).button();
	});
</script>
</head>
<body>

	<div align="center">
		<h1>Welcome to X-Calendar !</h1>
	</div>
	<div class="link" align="center">
		<form action="/loginController" onsubmit="return validate_form(this)"
			method="post">
			<table>
				<tr>
					<td>User Name:</td>
					<td><input type="text" name="userName" />
					</td>
				</tr>
				<tr>
					<td>Password:</td>
					<td><input type="password" name="password" />
					</td>
				</tr>
				
			</table>
			<%if(errorMessage != null) {%>
				<p style="color:#ff33ff"><%=errorMessage%></p>
				<%} %>
			<br /> <input type="submit" value="Login" />
		</form>
	</div>
	<div class="link" align="center">
		<p>
			<a href="register.jsp"> Don't have an account yet? </a>
		</p>
	</div>
</body>
</html>